package main

import (
	"fmt"
	"strconv"
)

type Stack struct {
	arr []int
}

func (s *Stack) Push(val int) {
	if s.arr == nil {
		s.arr = []int{val}
	} else {
		s.arr = append(s.arr, val)
	}
}

func (s *Stack) Pop() int {
	i := s.arr[len(s.arr)-1]
	s.arr = s.arr[:len(s.arr)-1]
	return i
}

func (s *Stack) String() (str string) {
	for _, v := range s.arr {
		str += strconv.Itoa(v) + ", "
	}
	return str
}

func main() {
	s := new(Stack)
	s.Push(1)
	s.Push(2)
	s.Push(3)
	s.Push(4)
	s.Push(5)

	pop := s.Pop()
	fmt.Println("pop1: ", pop)
	pop = s.Pop()
	fmt.Println("pop2: ", pop)
	fmt.Println("s: ", s)
}
